package br.ufc.si.sd.gui;

/*
 * AgendaGUI.java
 *
 * Created on 28 de Outubro de 2010, 10:41
 */
import br.ufc.si.sd.controle.AgendaControle;
import com.google.protobuf.InvalidProtocolBufferException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import protos.br.ufc.si.sd.gerado.AgendaEletronica.Person;

/**
 *
 * @author  Usuario
 */
public class AgendaGUI extends javax.swing.JFrame {

    private Person.Builder person;
    private AgendaControle agenda;

    /** Creates new form AgendaGUI */
    public AgendaGUI() {
        initComponents();
        agenda = new AgendaControle();
        tela_Cadastro.setVisible(false);
        tela_editar.setVisible(false);
        tela_excluir.setVisible(false);
        tela_inicial.setVisible(false);
        tela_listar.setVisible(false);
        tela_registro.setVisible(true);
        bloquearBotoes();
    }

    public void MenuInicial() {

        tela_Cadastro.setVisible(false);
        tela_editar.setVisible(false);
        tela_excluir.setVisible(false);
        tela_inicial.setVisible(true);
        tela_listar.setVisible(false);
        tela_registro.setVisible(false);

    }


    private void bloquearBotoes(){

    this.jButton_adicionar.setEnabled(false);
    this.jButton_editar.setEnabled(false);
    this.jButton_excluir.setEnabled(false);
    this.jButton_listar.setEnabled(false);
    }

    private void liberarBotoes(){

    this.jButton_adicionar.setEnabled(true);
    this.jButton_editar.setEnabled(true);
    this.jButton_excluir.setEnabled(true);
    this.jButton_listar.setEnabled(true);
    }



    public void limpaTela(JTextField nome, JTextField email, JTextField cel, JTextField dome, JTextField tra, JTextField id) {
        email.setText(null);
        id.setText(null);
        nome.setText(null);
        cel.setText(null);
        dome.setText(null);
        tra.setText(null);
    }

    private boolean validaCampos(String nome, String email, String id) {
        if ((nome == null || nome.trim().equals("")) || (id == null || id.trim().equals(""))
                || (email == null || email.trim().equals(""))) {
            return false;
        }
        return true;
    }
     private boolean validaCampos(String nome, String email) {
           if ((nome == null || nome.trim().equals(""))
                || (email == null || email.trim().equals(""))) {
            return false;
        }
        return true;
    }

    private boolean validaCampos() {
        String email = this.jTextField_email.getText();
        String id = this.jTextField_id.getText();
        String nome = this.jTextField_nome.getText();
        if ((nome == null || nome.trim().equals("")) || (id == null || id.trim().equals(""))
                || (email == null || email.trim().equals(""))) {
            return false;
        }

        return true;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane_gerenciaPanel = new javax.swing.JLayeredPane();
        tela_Cadastro = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTextField_id = new javax.swing.JTextField();
        jTextField_nome = new javax.swing.JTextField();
        jTextField_email = new javax.swing.JTextField();
        jTextField_tel_movel = new javax.swing.JTextField();
        jTextField_tel_domes = new javax.swing.JTextField();
        jTextField_tel_trab = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jButton_salvar = new javax.swing.JButton();
        jButton_cancelar = new javax.swing.JButton();
        jLabel25 = new javax.swing.JLabel();
        tela_inicial = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        tela_editar = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jTextField_id_busc = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jButton_buscaEdit = new javax.swing.JButton();
        jPanel_busca_editar = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jTextField_tel_movelEdit = new javax.swing.JTextField();
        jTextField_emailEdit = new javax.swing.JTextField();
        jTextField_nomeEdit = new javax.swing.JTextField();
        jTextField_tel_domesEdit = new javax.swing.JTextField();
        jTextField_tel_trabEdit = new javax.swing.JTextField();
        jButton_salvaEdi = new javax.swing.JButton();
        jButton_cancelarEdit = new javax.swing.JButton();
        jLabel26 = new javax.swing.JLabel();
        jButton_voltarEditar = new javax.swing.JButton();
        tela_listar = new javax.swing.JPanel();
        jLabel24 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea_contatos = new javax.swing.JTextArea();
        jButton_voltar = new javax.swing.JButton();
        tela_excluir = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jTextField_id_buscEx = new javax.swing.JTextField();
        jButton_buscaExcl = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        jPanel_Excluir = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jTextField_tel_movelEx = new javax.swing.JTextField();
        jTextField_emailEx = new javax.swing.JTextField();
        jTextField_nomeEx = new javax.swing.JTextField();
        jTextField_tel_domesEx = new javax.swing.JTextField();
        jTextField_tel_trabEx = new javax.swing.JTextField();
        jButton_excluirCont = new javax.swing.JButton();
        jButton_cancelarEx = new javax.swing.JButton();
        jButton_voltarExcluir = new javax.swing.JButton();
        tela_registro = new javax.swing.JPanel();
        jLabel28 = new javax.swing.JLabel();
        jTextField_nome_reg = new javax.swing.JTextField();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jButton_registrar = new javax.swing.JButton();
        jButton_cancelar_reg = new javax.swing.JButton();
        jLabel34 = new javax.swing.JLabel();
        jTextField_tel_trab_reg = new javax.swing.JTextField();
        jTextField_tel_domes_reg = new javax.swing.JTextField();
        jTextField_tel_movel_reg = new javax.swing.JTextField();
        jTextField_email_reg = new javax.swing.JTextField();
        jButton_adicionar = new javax.swing.JButton();
        jButton_editar = new javax.swing.JButton();
        jButton_excluir = new javax.swing.JButton();
        jButton_listar = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("AGENDA");

        tela_Cadastro.setBorder(javax.swing.BorderFactory.createTitledBorder("Cadastro"));

        jLabel1.setText(" *ID:");

        jLabel2.setText("*Nome:");

        jLabel3.setText("*E-mail");

        jLabel5.setText("Telefone Móvel:");

        jLabel6.setText("Telefone Domético:");

        jLabel7.setText("Telefone de Trabalho:");

        jLabel9.setText("NOVO CADASTRO");

        jButton_salvar.setText("Salvar");
        jButton_salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_salvarActionPerformed(evt);
            }
        });

        jButton_cancelar.setText("Cancelar");
        jButton_cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelarActionPerformed(evt);
            }
        });

        jLabel25.setText("* campo obrigatório");

        javax.swing.GroupLayout tela_CadastroLayout = new javax.swing.GroupLayout(tela_Cadastro);
        tela_Cadastro.setLayout(tela_CadastroLayout);
        tela_CadastroLayout.setHorizontalGroup(
            tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_CadastroLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addGap(27, 27, 27)
                .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTextField_email)
                    .addComponent(jTextField_tel_movel)
                    .addComponent(jTextField_tel_domes)
                    .addComponent(jTextField_tel_trab, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
                    .addComponent(jTextField_nome)
                    .addComponent(jTextField_id))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, tela_CadastroLayout.createSequentialGroup()
                .addContainerGap(142, Short.MAX_VALUE)
                .addComponent(jButton_salvar)
                .addGap(59, 59, 59)
                .addComponent(jButton_cancelar)
                .addGap(31, 31, 31))
            .addGroup(tela_CadastroLayout.createSequentialGroup()
                .addGap(101, 101, 101)
                .addComponent(jLabel9)
                .addContainerGap(153, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, tela_CadastroLayout.createSequentialGroup()
                .addContainerGap(228, Short.MAX_VALUE)
                .addComponent(jLabel25)
                .addContainerGap())
        );

        tela_CadastroLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton_cancelar, jButton_salvar});

        tela_CadastroLayout.setVerticalGroup(
            tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_CadastroLayout.createSequentialGroup()
                .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tela_CadastroLayout.createSequentialGroup()
                        .addGap(118, 118, 118)
                        .addComponent(jLabel4))
                    .addGroup(tela_CadastroLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel9)
                        .addGap(38, 38, 38)
                        .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jTextField_id, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(jTextField_nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jTextField_email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jTextField_tel_movel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jTextField_tel_domes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(jTextField_tel_trab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel25)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tela_CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_cancelar)
                    .addComponent(jButton_salvar))
                .addGap(27, 27, 27))
        );

        tela_CadastroLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton_cancelar, jButton_salvar});

        tela_Cadastro.setBounds(0, 0, 380, 320);
        jLayeredPane_gerenciaPanel.add(tela_Cadastro, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tela_inicial.setBorder(javax.swing.BorderFactory.createTitledBorder("Inicio"));

        jLabel8.setText("Escolha uma opção ao lado");

        javax.swing.GroupLayout tela_inicialLayout = new javax.swing.GroupLayout(tela_inicial);
        tela_inicial.setLayout(tela_inicialLayout);
        tela_inicialLayout.setHorizontalGroup(
            tela_inicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_inicialLayout.createSequentialGroup()
                .addGap(117, 117, 117)
                .addComponent(jLabel8)
                .addContainerGap(75, Short.MAX_VALUE))
        );
        tela_inicialLayout.setVerticalGroup(
            tela_inicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_inicialLayout.createSequentialGroup()
                .addGap(142, 142, 142)
                .addComponent(jLabel8)
                .addContainerGap(134, Short.MAX_VALUE))
        );

        tela_inicial.setBounds(0, 0, 380, 320);
        jLayeredPane_gerenciaPanel.add(tela_inicial, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tela_editar.setBorder(javax.swing.BorderFactory.createTitledBorder("Editar"));

        jLabel13.setText(" Digite ID:");

        jLabel16.setText("EDITAR CADASTRO");

        jButton_buscaEdit.setText("Buscar");
        jButton_buscaEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_buscaEditActionPerformed(evt);
            }
        });

        jLabel10.setText("Telefone de Trabalho*:");

        jLabel11.setText("E-mail*:");

        jLabel12.setText("Nome*:");

        jLabel14.setText("Telefone Móvel*:");

        jLabel15.setText("Telefone Domético*:");

        jButton_salvaEdi.setText("Editar");
        jButton_salvaEdi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_salvaEdiActionPerformed(evt);
            }
        });

        jButton_cancelarEdit.setText("Cancelar");
        jButton_cancelarEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelarEditActionPerformed(evt);
            }
        });

        jLabel26.setText("* Campo Obrigatório");

        javax.swing.GroupLayout jPanel_busca_editarLayout = new javax.swing.GroupLayout(jPanel_busca_editar);
        jPanel_busca_editar.setLayout(jPanel_busca_editarLayout);
        jPanel_busca_editarLayout.setHorizontalGroup(
            jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_busca_editarLayout.createSequentialGroup()
                .addGroup(jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_busca_editarLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12)
                            .addComponent(jLabel14)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextField_tel_movelEdit)
                            .addComponent(jTextField_emailEdit)
                            .addComponent(jTextField_nomeEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                            .addComponent(jTextField_tel_domesEdit)
                            .addComponent(jTextField_tel_trabEdit)
                            .addGroup(jPanel_busca_editarLayout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addComponent(jLabel26))))
                    .addGroup(jPanel_busca_editarLayout.createSequentialGroup()
                        .addGap(80, 80, 80)
                        .addComponent(jButton_salvaEdi)
                        .addGap(41, 41, 41)
                        .addComponent(jButton_cancelarEdit)))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        jPanel_busca_editarLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton_cancelarEdit, jButton_salvaEdi});

        jPanel_busca_editarLayout.setVerticalGroup(
            jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_busca_editarLayout.createSequentialGroup()
                .addContainerGap(22, Short.MAX_VALUE)
                .addGroup(jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jTextField_nomeEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jTextField_emailEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jTextField_tel_movelEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jTextField_tel_domesEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTextField_tel_trabEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel26)
                .addGap(16, 16, 16)
                .addGroup(jPanel_busca_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_cancelarEdit)
                    .addComponent(jButton_salvaEdi))
                .addContainerGap())
        );

        jPanel_busca_editarLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton_cancelarEdit, jButton_salvaEdi});

        jButton_voltarEditar.setText("Voltar");
        jButton_voltarEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_voltarEditarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout tela_editarLayout = new javax.swing.GroupLayout(tela_editar);
        tela_editar.setLayout(tela_editarLayout);
        tela_editarLayout.setHorizontalGroup(
            tela_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_editarLayout.createSequentialGroup()
                .addGroup(tela_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tela_editarLayout.createSequentialGroup()
                        .addGap(127, 127, 127)
                        .addComponent(jLabel16))
                    .addGroup(tela_editarLayout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(jPanel_busca_editar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(tela_editarLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField_id_busc, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButton_buscaEdit)
                        .addGap(18, 18, 18)
                        .addComponent(jButton_voltarEditar)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tela_editarLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton_buscaEdit, jButton_voltarEditar});

        tela_editarLayout.setVerticalGroup(
            tela_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_editarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel16)
                .addGap(18, 18, 18)
                .addGroup(tela_editarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jTextField_id_busc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton_buscaEdit)
                    .addComponent(jButton_voltarEditar))
                .addGap(18, 18, 18)
                .addComponent(jPanel_busca_editar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tela_editarLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton_buscaEdit, jButton_voltarEditar});

        tela_editar.setBounds(0, 0, 380, 320);
        jLayeredPane_gerenciaPanel.add(tela_editar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tela_listar.setBorder(javax.swing.BorderFactory.createTitledBorder("Listagem"));

        jLabel24.setText("MEUS CONTATOS");

        jTextArea_contatos.setColumns(20);
        jTextArea_contatos.setEditable(false);
        jTextArea_contatos.setRows(5);
        jScrollPane1.setViewportView(jTextArea_contatos);

        jButton_voltar.setText("Voltar");
        jButton_voltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_voltarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout tela_listarLayout = new javax.swing.GroupLayout(tela_listar);
        tela_listar.setLayout(tela_listarLayout);
        tela_listarLayout.setHorizontalGroup(
            tela_listarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_listarLayout.createSequentialGroup()
                .addGroup(tela_listarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tela_listarLayout.createSequentialGroup()
                        .addGap(144, 144, 144)
                        .addComponent(jLabel24))
                    .addGroup(tela_listarLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(47, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, tela_listarLayout.createSequentialGroup()
                .addContainerGap(168, Short.MAX_VALUE)
                .addComponent(jButton_voltar)
                .addGap(150, 150, 150))
        );
        tela_listarLayout.setVerticalGroup(
            tela_listarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_listarLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabel24)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton_voltar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tela_listar.setBounds(0, 0, 380, 320);
        jLayeredPane_gerenciaPanel.add(tela_listar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tela_excluir.setBorder(javax.swing.BorderFactory.createTitledBorder("Excluir"));

        jLabel17.setText(" Digite ID:");

        jButton_buscaExcl.setText("Buscar");
        jButton_buscaExcl.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_buscaExclActionPerformed(evt);
            }
        });

        jLabel18.setText("EXCLUIR CADASTRO");

        jLabel19.setText("Telefone de Trabalho:");

        jLabel20.setText("E-mail");

        jLabel21.setText("Nome:");

        jLabel22.setText("Telefone Móvel:");

        jLabel23.setText("Telefone Domético:");

        jButton_excluirCont.setText("Excluir");
        jButton_excluirCont.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_excluirContActionPerformed(evt);
            }
        });

        jButton_cancelarEx.setText("Cancelar");
        jButton_cancelarEx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelarExActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel_ExcluirLayout = new javax.swing.GroupLayout(jPanel_Excluir);
        jPanel_Excluir.setLayout(jPanel_ExcluirLayout);
        jPanel_ExcluirLayout.setHorizontalGroup(
            jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_ExcluirLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton_excluirCont, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel19)
                        .addComponent(jLabel20)
                        .addComponent(jLabel21)
                        .addComponent(jLabel22)
                        .addComponent(jLabel23)))
                .addGroup(jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_ExcluirLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextField_tel_movelEx)
                            .addComponent(jTextField_emailEx)
                            .addComponent(jTextField_nomeEx, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                            .addComponent(jTextField_tel_domesEx)
                            .addComponent(jTextField_tel_trabEx)))
                    .addGroup(jPanel_ExcluirLayout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addComponent(jButton_cancelarEx)))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        jPanel_ExcluirLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton_cancelarEx, jButton_excluirCont});

        jPanel_ExcluirLayout.setVerticalGroup(
            jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_ExcluirLayout.createSequentialGroup()
                .addContainerGap(22, Short.MAX_VALUE)
                .addGroup(jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(jTextField_nomeEx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(jTextField_emailEx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(jTextField_tel_movelEx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(jTextField_tel_domesEx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(jTextField_tel_trabEx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addGroup(jPanel_ExcluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_cancelarEx)
                    .addComponent(jButton_excluirCont))
                .addGap(22, 22, 22))
        );

        jPanel_ExcluirLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton_cancelarEx, jButton_excluirCont});

        jButton_voltarExcluir.setText("Voltar");
        jButton_voltarExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_voltarExcluirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout tela_excluirLayout = new javax.swing.GroupLayout(tela_excluir);
        tela_excluir.setLayout(tela_excluirLayout);
        tela_excluirLayout.setHorizontalGroup(
            tela_excluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_excluirLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(tela_excluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel_Excluir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(tela_excluirLayout.createSequentialGroup()
                        .addGroup(tela_excluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel18)
                            .addGroup(tela_excluirLayout.createSequentialGroup()
                                .addComponent(jLabel17)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField_id_buscEx, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton_buscaExcl)))
                        .addGap(18, 18, 18)
                        .addComponent(jButton_voltarExcluir)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tela_excluirLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton_buscaExcl, jButton_voltarExcluir});

        tela_excluirLayout.setVerticalGroup(
            tela_excluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_excluirLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel18)
                .addGap(18, 18, 18)
                .addGroup(tela_excluirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jTextField_id_buscEx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton_buscaExcl)
                    .addComponent(jButton_voltarExcluir))
                .addGap(18, 18, 18)
                .addComponent(jPanel_Excluir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tela_excluirLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton_buscaExcl, jButton_voltarExcluir});

        tela_excluir.setBounds(0, 0, 380, 320);
        jLayeredPane_gerenciaPanel.add(tela_excluir, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tela_registro.setBorder(javax.swing.BorderFactory.createTitledBorder("Registro"));

        jLabel28.setText("REGISTRO");

        jLabel29.setText("*Nome:");

        jLabel30.setText("*E-mail");

        jLabel31.setText("Telefone Móvel:");

        jLabel32.setText("Telefone Domético:");

        jLabel33.setText("Telefone de Trabalho:");

        jButton_registrar.setText("Salvar");
        jButton_registrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_registrarActionPerformed(evt);
            }
        });

        jButton_cancelar_reg.setText("Cancelar");
        jButton_cancelar_reg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelar_regActionPerformed(evt);
            }
        });

        jLabel34.setText("* campo obrigatório");

        javax.swing.GroupLayout tela_registroLayout = new javax.swing.GroupLayout(tela_registro);
        tela_registro.setLayout(tela_registroLayout);
        tela_registroLayout.setHorizontalGroup(
            tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_registroLayout.createSequentialGroup()
                .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tela_registroLayout.createSequentialGroup()
                        .addGap(143, 143, 143)
                        .addComponent(jLabel28))
                    .addGroup(tela_registroLayout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(tela_registroLayout.createSequentialGroup()
                                .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel33)
                                    .addComponent(jLabel30)
                                    .addComponent(jLabel29)
                                    .addComponent(jLabel31)
                                    .addComponent(jLabel32))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jTextField_email_reg)
                                    .addComponent(jTextField_tel_movel_reg)
                                    .addComponent(jTextField_tel_domes_reg)
                                    .addComponent(jTextField_tel_trab_reg, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
                                    .addComponent(jTextField_nome_reg))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, tela_registroLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel34))))
                    .addGroup(tela_registroLayout.createSequentialGroup()
                        .addGap(79, 79, 79)
                        .addComponent(jButton_registrar)
                        .addGap(53, 53, 53)
                        .addComponent(jButton_cancelar_reg)))
                .addContainerGap(28, Short.MAX_VALUE))
        );

        tela_registroLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton_cancelar_reg, jButton_registrar});

        tela_registroLayout.setVerticalGroup(
            tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tela_registroLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel28)
                .addGap(18, 18, 18)
                .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel29)
                    .addComponent(jTextField_nome_reg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel30)
                    .addComponent(jTextField_email_reg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel31)
                    .addComponent(jTextField_tel_movel_reg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel32)
                    .addComponent(jTextField_tel_domes_reg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel33)
                    .addComponent(jTextField_tel_trab_reg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel34)
                .addGap(33, 33, 33)
                .addGroup(tela_registroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_cancelar_reg)
                    .addComponent(jButton_registrar))
                .addGap(29, 29, 29))
        );

        tela_registroLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton_cancelar_reg, jButton_registrar});

        tela_registro.setBounds(0, 0, 380, 320);
        jLayeredPane_gerenciaPanel.add(tela_registro, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton_adicionar.setText("Adicionar");
        jButton_adicionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_adicionarActionPerformed(evt);
            }
        });

        jButton_editar.setText("Editar");
        jButton_editar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_editarActionPerformed(evt);
            }
        });

        jButton_excluir.setText("Excluir");
        jButton_excluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_excluirActionPerformed(evt);
            }
        });

        jButton_listar.setText("Listar");
        jButton_listar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_listarActionPerformed(evt);
            }
        });

        jMenu1.setText("Arquivo");

        jMenuItem1.setText("Adicionar Contato");
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Sair");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton_adicionar)
                    .addComponent(jButton_editar)
                    .addComponent(jButton_excluir)
                    .addComponent(jButton_listar))
                .addContainerGap(412, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(99, Short.MAX_VALUE)
                    .addComponent(jLayeredPane_gerenciaPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton_adicionar, jButton_editar, jButton_excluir, jButton_listar});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(69, 69, 69)
                .addComponent(jButton_adicionar, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addComponent(jButton_editar)
                .addGap(41, 41, 41)
                .addComponent(jButton_excluir)
                .addGap(41, 41, 41)
                .addComponent(jButton_listar)
                .addContainerGap(64, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(24, 24, 24)
                    .addComponent(jLayeredPane_gerenciaPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(22, Short.MAX_VALUE)))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton_adicionar, jButton_editar, jButton_excluir, jButton_listar});

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton_adicionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_adicionarActionPerformed
    tela_Cadastro.setVisible(true);
    tela_editar.setVisible(false);
    tela_excluir.setVisible(false);
    tela_inicial.setVisible(false);
    tela_listar.setVisible(false);
    bloquearBotoes();
}//GEN-LAST:event_jButton_adicionarActionPerformed

private void jButton_editarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_editarActionPerformed
    tela_Cadastro.setVisible(false);
    tela_editar.setVisible(true);
    tela_excluir.setVisible(false);
    tela_inicial.setVisible(false);
    tela_listar.setVisible(false);
    jPanel_busca_editar.setVisible(false);
    bloquearBotoes();
}//GEN-LAST:event_jButton_editarActionPerformed

private void jButton_excluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_excluirActionPerformed
    tela_Cadastro.setVisible(false);
    tela_editar.setVisible(false);
    tela_excluir.setVisible(true);
    tela_inicial.setVisible(false);
    tela_listar.setVisible(false);
    jPanel_Excluir.setVisible(false);
    bloquearBotoes();
}//GEN-LAST:event_jButton_excluirActionPerformed

private void jButton_listarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_listarActionPerformed
    //agenda = new AgendaControle();
    tela_Cadastro.setVisible(false);
    tela_editar.setVisible(false);
    tela_excluir.setVisible(false);
    tela_inicial.setVisible(false);
    tela_listar.setVisible(true);
    jTextArea_contatos.setText(null);
    bloquearBotoes();
    try {

        List<Person> persons = this.agenda.listaPerson();

        if (persons != null && !persons.isEmpty()) {
            this.jTextArea_contatos.append("Meus Contatos são: \n");
            for (Person p : persons) {
                this.jTextArea_contatos.append("ID: " + p.getId() + "\n");
                this.jTextArea_contatos.append("Nome: " + p.getName() + "\n");
                this.jTextArea_contatos.append("Email: " + p.getEmail() + "\n");
                this.jTextArea_contatos.append("Celular: " + p.getCelular() + "\n");
                this.jTextArea_contatos.append("Tel. Doméstico: " + p.getTelDomestico() + "\n");
                this.jTextArea_contatos.append("Tel. Trabalho: " + p.getTelTrabalho() + "\n");
                this.jTextArea_contatos.append("-------------------------------------------------------------\n");
            }
        } else {
            this.jTextArea_contatos.append("Sem contatos no momento!");
        }
    } catch (InvalidProtocolBufferException ex) {
        JOptionPane.showMessageDialog(null, "Erro ao Listar:" + ex.getMessage());
    }
}//GEN-LAST:event_jButton_listarActionPerformed

private void jButton_salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_salvarActionPerformed
    if (validaCampos()) {
        person = Person.newBuilder();
        //agenda = new AgendaControle();
        person.setId(Integer.parseInt(this.jTextField_id.getText()));
        person.setEmail(this.jTextField_email.getText());
        person.setName(this.jTextField_nome.getText());
        String cel = this.jTextField_tel_movel.getText();
        String domestico = this.jTextField_tel_domes.getText();
        String trabalho = this.jTextField_tel_trab.getText();
        if (cel.trim().equals("") || cel == null) {
            cel = "Não Informado";
        }
        if (domestico.trim().equals("") || domestico == null) {
            domestico = "Não Informado";
        }
        if (trabalho.trim().equals("") || trabalho == null) {
            trabalho = "Não Informado";
        }
        person.setCelular(cel);
        person.setTelDomestico(domestico);
        person.setTelTrabalho(trabalho);
        try {
            String mensagem = this.agenda.addPerson(person.build());
            JOptionPane.showMessageDialog(null, "" + mensagem);
            limpaTela(jTextField_nome, jTextField_id, jTextField_tel_domes, jTextField_tel_movel, jTextField_tel_trab, jTextField_email);

        } catch (InvalidProtocolBufferException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao Cadastrar:" + ex.getMessage());

        }

    } else {

        JOptionPane.showMessageDialog(null, "Preencha todos os campos obrigatórios!");
    }



}//GEN-LAST:event_jButton_salvarActionPerformed

private void jButton_cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelarActionPerformed
    MenuInicial();
    liberarBotoes();
}//GEN-LAST:event_jButton_cancelarActionPerformed

private void jButton_buscaEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_buscaEditActionPerformed
    //agenda = new AgendaControle();

    Person p;
    String id = this.jTextField_id_busc.getText();
    if (!(id.trim().equals("") || id == null)) {
        try {
            p = agenda.buscarPerson(Integer.parseInt(id));
            if (p != null) {
                this.jPanel_busca_editar.setVisible(true);
                this.jTextField_emailEdit.setText(p.getEmail());
                this.jTextField_nomeEdit.setText(p.getName());
                this.jTextField_tel_domesEdit.setText(p.getTelDomestico());
                this.jTextField_tel_movelEdit.setText(p.getCelular());
                this.jTextField_tel_trabEdit.setText(p.getTelTrabalho());
                this.jTextField_id_busc.setEditable(false);
                this.jButton_voltarEditar.setEnabled(false);
                this.jButton_buscaEdit.setEnabled(false);
            } else {
                JOptionPane.showMessageDialog(null, "Contato não encontrado");
            }

        } catch (InvalidProtocolBufferException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao Editar : " + ex.getMessage());
            Logger.getLogger(AgendaGUI.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {

        JOptionPane.showMessageDialog(null, "Digite ID a ser buscado!");
    }
}//GEN-LAST:event_jButton_buscaEditActionPerformed

private void jButton_cancelarEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelarEditActionPerformed
    this.jButton_buscaEdit.setEnabled(true);
    this.jButton_voltarEditar.setEnabled(true);
    this.jTextField_id_busc.setEditable(true);
    this.jPanel_busca_editar.setVisible(false);
}//GEN-LAST:event_jButton_cancelarEditActionPerformed

private void jButton_buscaExclActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_buscaExclActionPerformed
    //agenda = new AgendaControle();

    Person p;
    String id = this.jTextField_id_buscEx.getText();
    if (!(id.trim().equals("") || id == null)) {
        try {
            p = agenda.buscarPerson(Integer.parseInt(id));
            if (p != null) {
                this.jPanel_Excluir.setVisible(true);
                this.jTextField_emailEx.setText(p.getEmail());
                this.jTextField_nomeEx.setText(p.getName());
                this.jTextField_tel_domesEx.setText(p.getTelDomestico());
                this.jTextField_tel_movelEx.setText(p.getCelular());
                this.jTextField_tel_trabEx.setText(p.getTelTrabalho());
                this.jTextField_id_buscEx.setEditable(false);
                this.jButton_voltarExcluir.setEnabled(false);
                this.jButton_buscaExcl.setEnabled(false);
                
            } else {
                JOptionPane.showMessageDialog(null, "Contato não encontrado");
            }

        } catch (InvalidProtocolBufferException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao Editar : " + ex.getMessage());
            Logger.getLogger(AgendaGUI.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        JOptionPane.showMessageDialog(null, "Digite ID a ser buscado!");
    }
}//GEN-LAST:event_jButton_buscaExclActionPerformed

private void jButton_cancelarExActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelarExActionPerformed
this.jButton_buscaExcl.setEnabled(true);
this.jButton_voltarExcluir.setEnabled(true);
this.jTextField_id_buscEx.setEditable(true);
this.jPanel_Excluir.setVisible(false);

    
}//GEN-LAST:event_jButton_cancelarExActionPerformed

private void jButton_voltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_voltarActionPerformed

    jTextArea_contatos.setText(null);
    MenuInicial();
    liberarBotoes();
}//GEN-LAST:event_jButton_voltarActionPerformed

private void jButton_excluirContActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_excluirContActionPerformed

    Person.Builder p = Person.newBuilder();
    p.setId(Integer.parseInt(this.jTextField_id_buscEx.getText()));
    p.setCelular(this.jTextField_tel_movelEx.getText());
    p.setEmail(this.jTextField_emailEx.getText());
    p.setName(this.jTextField_nomeEx.getText());
    p.setTelDomestico(this.jTextField_tel_domesEx.getText());
    p.setTelTrabalho(this.jTextField_tel_trabEx.getText());
    String men = null;
    try {
        men = agenda.removePerson(p.build());
        JOptionPane.showMessageDialog(null, men);
        this.jTextField_id_buscEx.setEditable(true);
        this.jButton_buscaExcl.setEnabled(true);
        this.jButton_voltarExcluir.setEnabled(true);
        this.jPanel_Excluir.setVisible(false);
        limpaTela(jTextField_nomeEx, jTextField_id_buscEx, jTextField_emailEx, jTextField_tel_domesEx, jTextField_tel_trabEx, jTextField_tel_movelEx);
    } catch (InvalidProtocolBufferException ex) {
        JOptionPane.showMessageDialog(null, men + " erro: " + ex.getMessage());
    }
}//GEN-LAST:event_jButton_excluirContActionPerformed

private void jButton_salvaEdiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_salvaEdiActionPerformed

    Person.Builder per = Person.newBuilder();
    String id = this.jTextField_id_busc.getText();
    String nome = this.jTextField_nomeEdit.getText();
    String email = this.jTextField_emailEdit.getText();
    String cel = this.jTextField_tel_movelEdit.getText();
    String trab = this.jTextField_tel_trabEdit.getText();
    String domes = this.jTextField_tel_domesEdit.getText();
    if (validaCampos(nome, email, id)) {

        if (cel.trim().equals("") || cel == null) {
            cel = "Não Informado";
        }
        if (domes.trim().equals("") || domes == null) {
            domes = "Não Informado";
        }
        if (trab.trim().equals("") || trab == null) {
            trab = "Não Informado";
        }
        per.setId(Integer.parseInt(id));
        per.setName(nome);
        per.setEmail(email);
        per.setCelular(cel);
        per.setTelDomestico(domes);
        per.setTelTrabalho(trab);
        String men = null;
        try {
            men = agenda.editaPerson(per.build());
            JOptionPane.showMessageDialog(null, men);
            this.jTextField_id_busc.setEditable(true);
            this.jButton_voltarEditar.setEnabled(true);
            this.jButton_buscaEdit.setEnabled(true);
            this.jPanel_busca_editar.setVisible(false);
            limpaTela(jTextField_nomeEdit, jTextField_id_busc, jTextField_emailEdit, jTextField_tel_domesEdit, jTextField_tel_trabEdit, jTextField_tel_movelEdit);
        } catch (InvalidProtocolBufferException ex) {
            JOptionPane.showMessageDialog(null, men + " erro: " + ex.getMessage());
        }

    }else{
    JOptionPane.showMessageDialog(null,"Preencha todos os Campos Obrigatórios!");
    }
}//GEN-LAST:event_jButton_salvaEdiActionPerformed

private void jButton_voltarEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_voltarEditarActionPerformed
MenuInicial();
liberarBotoes();
}//GEN-LAST:event_jButton_voltarEditarActionPerformed

private void jButton_voltarExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_voltarExcluirActionPerformed
MenuInicial();
liberarBotoes();
}//GEN-LAST:event_jButton_voltarExcluirActionPerformed

private void jButton_registrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_registrarActionPerformed

    if (validaCampos(jTextField_email_reg.getText(),this.jTextField_nome_reg.getText())) {
        person = Person.newBuilder();
        //agenda = new AgendaControle();
        person.setId(-1000);
        person.setEmail(this.jTextField_email_reg.getText());
        person.setName(this.jTextField_nome_reg.getText());
        String cel = this.jTextField_tel_movel_reg.getText();
        String domestico = this.jTextField_tel_domes_reg.getText();
        String trabalho = this.jTextField_tel_trab_reg.getText();
        if (cel.trim().equals("") || cel == null) {
            cel = "Não Informado";
        }
        if (domestico.trim().equals("") || domestico == null) {
            domestico = "Não Informado";
        }
        if (trabalho.trim().equals("") || trabalho == null) {
            trabalho = "Não Informado";
        }
        person.setCelular(cel);
        person.setTelDomestico(domestico);
        person.setTelTrabalho(trabalho);
        try {
            String mensagem = this.agenda.registrar(person.build());
            JOptionPane.showMessageDialog(null, "" + mensagem);
            MenuInicial();
            liberarBotoes();

        } catch (InvalidProtocolBufferException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao Cadastrar:" + ex.getMessage());

        }

    } else {

        JOptionPane.showMessageDialog(null, "Preencha todos os campos obrigatórios!");
    }

 

}//GEN-LAST:event_jButton_registrarActionPerformed

private void jButton_cancelar_regActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelar_regActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jButton_cancelar_regActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new AgendaGUI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_adicionar;
    private javax.swing.JButton jButton_buscaEdit;
    private javax.swing.JButton jButton_buscaExcl;
    private javax.swing.JButton jButton_cancelar;
    private javax.swing.JButton jButton_cancelarEdit;
    private javax.swing.JButton jButton_cancelarEx;
    private javax.swing.JButton jButton_cancelar_reg;
    private javax.swing.JButton jButton_editar;
    private javax.swing.JButton jButton_excluir;
    private javax.swing.JButton jButton_excluirCont;
    private javax.swing.JButton jButton_listar;
    private javax.swing.JButton jButton_registrar;
    private javax.swing.JButton jButton_salvaEdi;
    private javax.swing.JButton jButton_salvar;
    private javax.swing.JButton jButton_voltar;
    private javax.swing.JButton jButton_voltarEditar;
    private javax.swing.JButton jButton_voltarExcluir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane_gerenciaPanel;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel_Excluir;
    private javax.swing.JPanel jPanel_busca_editar;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea_contatos;
    private javax.swing.JTextField jTextField_email;
    private javax.swing.JTextField jTextField_emailEdit;
    private javax.swing.JTextField jTextField_emailEx;
    private javax.swing.JTextField jTextField_email_reg;
    private javax.swing.JTextField jTextField_id;
    private javax.swing.JTextField jTextField_id_busc;
    private javax.swing.JTextField jTextField_id_buscEx;
    private javax.swing.JTextField jTextField_nome;
    private javax.swing.JTextField jTextField_nomeEdit;
    private javax.swing.JTextField jTextField_nomeEx;
    private javax.swing.JTextField jTextField_nome_reg;
    private javax.swing.JTextField jTextField_tel_domes;
    private javax.swing.JTextField jTextField_tel_domesEdit;
    private javax.swing.JTextField jTextField_tel_domesEx;
    private javax.swing.JTextField jTextField_tel_domes_reg;
    private javax.swing.JTextField jTextField_tel_movel;
    private javax.swing.JTextField jTextField_tel_movelEdit;
    private javax.swing.JTextField jTextField_tel_movelEx;
    private javax.swing.JTextField jTextField_tel_movel_reg;
    private javax.swing.JTextField jTextField_tel_trab;
    private javax.swing.JTextField jTextField_tel_trabEdit;
    private javax.swing.JTextField jTextField_tel_trabEx;
    private javax.swing.JTextField jTextField_tel_trab_reg;
    private javax.swing.JPanel tela_Cadastro;
    private javax.swing.JPanel tela_editar;
    private javax.swing.JPanel tela_excluir;
    private javax.swing.JPanel tela_inicial;
    private javax.swing.JPanel tela_listar;
    private javax.swing.JPanel tela_registro;
    // End of variables declaration//GEN-END:variables


}
